package cn.shyouchi.wuguanjia.android.ui.statistic;

import com.chad.library.adapter.base.BaseMultiItemQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.chad.library.adapter.base.entity.MultiItemEntity;

import java.util.List;

import cn.shyouchi.wuguanjia.android.R;
import cn.shyouchi.wuguanjia.android.ui.statistic.user.AbseUser;
import cn.shyouchi.wuguanjia.android.ui.statistic.user.EarlyUser;
import cn.shyouchi.wuguanjia.android.ui.statistic.user.LateUser;
import cn.shyouchi.wuguanjia.android.ui.statistic.user.OutUser;
import cn.shyouchi.wuguanjia.android.ui.statistic.user.PracticeUser;
import cn.shyouchi.wuguanjia.android.ui.statistic.user.SecondedUser;

/**
 * Created by Eenie on 2017/1/24 at 10:23
 * Email: 472279981@qq.com
 * Des:
 */

public class StatisticMonthSignDetailAdapter extends BaseMultiItemQuickAdapter<MultiItemEntity, BaseViewHolder> {

    public static final int MONTH_SIGN_TYPE_LATE = 0;//迟到
    public static final int MONTH_SIGN_TYPE_LEAVE = 1;//请假
    public static final int MONTH_SIGN_TYPE_ABSE = 2;//旷工
    public static final int MONTH_SIGN_TYPE_OUT = 3;//外出
    public static final int MONTH_SIGN_TYPE_PRAC= 4;//实习
    public static final int MONTH_SIGN_TYPE_SECO = 5;//借调
    public static final int MONTH_SIGN_TYPE_EARLY = 6;//早退
    public static final int MONTH_SIGN_TYPE_OVER = 7;//加班

    public StatisticMonthSignDetailAdapter(List<MultiItemEntity> data) {
        super(data);
        addItemType(MONTH_SIGN_TYPE_LATE, R.layout.item_month_statistic_late_layout);
        addItemType(MONTH_SIGN_TYPE_EARLY, R.layout.item_month_statistic_late_layout);
        addItemType(MONTH_SIGN_TYPE_ABSE, R.layout.item_month_statistic_abse_layout);
        addItemType(MONTH_SIGN_TYPE_OUT, R.layout.item_month_statistic_out_layout);
        addItemType(MONTH_SIGN_TYPE_PRAC, R.layout.item_month_statistic_practice_layout);
        addItemType(MONTH_SIGN_TYPE_SECO, R.layout.item_month_statistic_seconded_layout);
    }

    @Override
    protected void convert(BaseViewHolder holder, MultiItemEntity entity) {


        switch (entity.getItemType()) {
            case MONTH_SIGN_TYPE_LATE:
                LateUser lateUser = (LateUser) entity;
                holder.setText(R.id.tv_name, lateUser.getName());
                holder.setText(R.id.tv_time, lateUser.getCreated_at());
                break;
            case MONTH_SIGN_TYPE_EARLY:
                EarlyUser earlyUser = (EarlyUser) entity;
                holder.setText(R.id.tv_name, earlyUser.getName());
                holder.setText(R.id.tv_time, earlyUser.getCreated_at());
                break;
            case MONTH_SIGN_TYPE_ABSE:
                AbseUser abseUser = (AbseUser) entity;
                holder.setText(R.id.tv_name, abseUser.getName());
                holder.setText(R.id.tv_time, abseUser.getDay());
                holder.setText(R.id.tv_rank, abseUser.getServicesname());
                break;
            case MONTH_SIGN_TYPE_PRAC:
                PracticeUser practiceUser = (PracticeUser) entity;
                holder.setText(R.id.tv_name, practiceUser.getUser());
                holder.setText(R.id.tv_rank, practiceUser.getService());
                holder.setText(R.id.tv_time, practiceUser.getCreated_at());

                break;
            case MONTH_SIGN_TYPE_SECO:
                SecondedUser secondedUser = (SecondedUser) entity;
                holder.setText(R.id.tv_name, secondedUser.getUser());
                holder.setText(R.id.tv_rank, secondedUser.getService());
                holder.setText(R.id.tv_time, secondedUser.getCreated_at());
                break;
            case MONTH_SIGN_TYPE_OUT:
                OutUser outUser = (OutUser) entity;
                holder.setText(R.id.tv_name, outUser.getUser());
                holder.setText(R.id.tv_addr, outUser.getAddress());
                holder.setText(R.id.tv_time, outUser.getCreated_at());
                break;
        }
    }
}
